CreateShape
Creates a shape with the parameters specified.
Syntax
expression.CreateShape(shapeType, width, height, fill, stroke);
expression
- A variable that represents a Api class.
Parameters
Name | Required/Optional | Data type | Default | Description |
---|---|---|---|---|
shapeType | Optional | ShapeType | "rect" | The shape type which specifies the preset shape geometry. |
width | Optional | EMU | 914400 | The shape width in English measure units. |
height | Optional | EMU | 914400 | The shape height in English measure units. |
fill | Optional | ApiFill | Api.CreateNoFill() | The color or pattern used to fill the shape. |
stroke | Optional | ApiStroke | Api.CreateStroke(0, Api.CreateNoFill()) | The stroke used to create the element shadow. |
Returns
Example
This example creates a shape using the 'rect' preset.
let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let gs1 = Api.CreateGradientStop(Api.CreateRGBColor(255, 213, 191), 0);
let gs2 = Api.CreateGradientStop(Api.CreateRGBColor(255, 111, 61), 100000);
let fill = Api.CreateLinearGradientFill([gs1, gs2], 5400000);
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
let shape = Api.CreateShape("rect", 5930900, 395605, fill, stroke);
paragraph.AddDrawing(shape);